﻿using EntityFramework.Entity.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YouTravel.DomainModels;

namespace Repositories.Configuration
{
    public class UserMap : EntityConfigurationBase<User>
    {
        public UserMap()
        {

            this.Property(p => p.Login).HasMaxLength(20).IsRequired();
            this.Property(p => p.PassWord).HasMaxLength(32).IsRequired();
            this.Property(p => p.Name).HasMaxLength(20).IsRequired();
            this.Property(p => p.Phone).HasMaxLength(11).IsRequired();

            this.HasOptional(p => p.Branch).WithMany().HasForeignKey(f => f.BranchId);
            this.HasOptional(p => p.Special).WithMany().HasForeignKey(f => f.SpecialId);
            this.HasOptional(p => p.Creater).WithMany().HasForeignKey(f => f.CreaterId);
            this.HasOptional(p => p.Updater).WithMany().HasForeignKey(f => f.UpdaterId);
        }
    }
}
